<template>
  <el-dialog :title="title" :visible.sync="visible" width="1000px" append-to-body destroy-on-close>
    <org-tree ref="tree" @selectChange="handleSelectChange"></org-tree>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="buttonLoading" type="primary" @click="submitForm"> 确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import OrgTree from '@/views/manage/org/OrgTree.vue'

export default {
  name: 'UserSelectDiag',
  components: { OrgTree },
  data() {
    return {
      visible: false,
      title: '用户选择',
      buttonStyle: 'solid',
      // 按钮loading
      buttonLoading: false,
      selectedUserIds: [],
      selectedUserRows: []
    }
  },
  methods: {
    submitForm() {
      this.visible = false
      this.$emit('ok', this.selectedUserIds, this.selectedUserRows)
    },
    cancel() {
      this.visible = false
    },
    handleSelectChange(ids, rows) {
      this.selectedUserIds = ids
      this.selectedUserRows = rows
      this.$emit('selectChange', ids, rows)
    }
  }
}
</script>

<style scoped></style>
